package com.demo.chapter5stream2;

import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Stream;

public class File {

	public static void demo(){
		//一个文档里有多少不一样的单词
		long uniqueWords = 0;
		try(Stream<String> lines = Files.lines(Paths.get("data.txt"), Charset.defaultCharset())){
			lines.flatMap(s -> Arrays.stream(s.split(" "))).distinct().count();
		}catch (Exception e) {
					// TODO: handle exception
				}
	}

}
